if (typeof (mediator) == 'undefined')
	mediator = {};

if (typeof (mediator.studied) == 'undefined')
	mediator.studied = {};

mediator.studied.appView = function() {
	var self = this;
	self.studies = ko.observableArray();
	self.studySelected = ko.observable();
	self.timeTables = ko.observableArray();
	self.menuClick = function(data, event){
		var data = data.course().getAllTimeTable();
		pushTimeTablesArray(data.tts, self.timeTables);
	};
	
	return this;
}
mediator.studied.createViewMediator = function(options) {
	var settings = $.extend({
		pid : 0
	}, options || {});
	
	var appView = new mediator.studied.appView();
	mediator.studied.renderView();
	
	var data = getPersonsStudies(settings.pid);
	pushStudiesArray(data, appView.studies);
	var viewNode = $('#main')[0];
	applyBindings(appView, viewNode);
}



mediator.studied.renderView = function(){
	$('#unAnyStudy').attr('data-bind', 'visible : studies().length < 1');
	$('#courses').attr('data-bind', 'foreach : studies');
	$('#courseName').attr('data-bind',
	'text : course().name, click : function(data, event){$parent.menuClick(data,event);}');
}